package com.open.capacity.recuritment.service.impl;

import com.open.capacity.common.exception.service.ServiceException;
import com.open.capacity.common.model.CrmIndustry;
import com.open.capacity.common.model.SysUser;
import com.open.capacity.recuritment.Dto.IndustryDto;
import com.open.capacity.recuritment.Dto.SysUserExcel;
import com.open.capacity.recuritment.dao.IIndustryDao;
import com.open.capacity.recuritment.service.IIndustryService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Vector;

/**
 * @description:
 * @date:2021/5/19 下午6:36
 * @author:jxy
 */
@Service
public class IndustryServiceImpl implements IIndustryService {
    @Resource
    private IIndustryDao iIndustryDao;

    @Override
    public Vector<CrmIndustry> findIndustry(Long pid) {
        Vector<CrmIndustry> vector = iIndustryDao.findIndustry(pid);
        return vector;
    }

    @Override
    public Vector<CrmIndustry> findPosition(Long pid) {
        Vector<CrmIndustry> vector = iIndustryDao.findPosition(pid);
        return vector;
    }

    @Override
    public Vector<IndustryDto> selectUnemployed(Long industry, Long position, Long employedStatus,Long page,Long limit) {
        Vector<IndustryDto> vector = iIndustryDao.selectUnemployed(industry,position,employedStatus,page,limit);
        return vector;
    }

    @Override
    public List<SysUserExcel> findAllUsers(Map<String, Object> params)  throws ServiceException {
        try {
            List<SysUserExcel> sysUserExcels = new ArrayList<>();
            List<IndustryDto> list = iIndustryDao.findList(params);

            for (IndustryDto industryDto : list){
                SysUserExcel sysUserExcel = new SysUserExcel();
                BeanUtils.copyProperties(industryDto,sysUserExcel);
                sysUserExcels.add(sysUserExcel);
            }
            return sysUserExcels;
        } catch (BeansException e) {
            throw new ServiceException(e);
        }
    }


}
